#include <iostream>
#include <cstdio>
using namespace std;
const int MAXN = 64;
const int INF = 1e9;

int a[MAXN][MAXN];
int free_sol[MAXN];
int use[MAXN]; 
int global_ans;
int n, m;

inline void read() {
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) a[i][i] = 1, a[i][n + 1] = 1;  // a[i][n + 1] is the result of posture
	for (int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		a[u][v] = 1;
		a[v][u] = 1;
	}
}

void dfs(int now, int ans) {
	if (ans > global_ans) return;
	if (now <= 0) {
		global_ans = min(global_ans, ans);
		return;
	}
	
	if (free_sol[now]) {
		use[now] = true;
		dfs(now - 1, ans + 1);
		use[now] = false;
		dfs(now - 1, ans);
	} else {
		use[now] = a[now][n + 1];
		for (int i = now + 1; i <= n; i++) if (a[now][i]) use[now] ^= use[i];
		if (use[now]) dfs(now - 1, ans + 1);
		else dfs(now - 1, ans);
	}
}

inline void solve() {
	for (int i = 1; i <= n; i++) free_sol[i] = true;
	for (int i = 1; i <= n; i++) {
		for (int j = i; j <= n; j++) {
			if (not a[j][i]) continue;
			for (int k = i; k <= n + 1; k++) swap(a[i][k], a[j][k]);
			break;
		}
		
		if (not a[i][i]) continue;
		
		for (int j = i + 1; j <= n; j++) {
			if (not a[j][i]) continue;
			for (int k = i; k <= n + 1; k++) a[j][k] ^= a[i][k];
		}
		free_sol[i] = false;
	}
	for(int i = 1;i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			printf("%d ", a[i][j]);
		}
		printf("%d\n", a[i][n + 1]);
	}
	global_ans = INF;
	dfs(n, 0);
	printf("%d\n", global_ans);
}

int main() {
#ifdef LOCAL
	freopen("test.in", "r", stdin);
#endif
	freopen("in.txt", "r", stdin);
//	freopen("haoi13t5.out", "w", stdout);
	read();
	solve();
	return 0;
}
